﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data.SqlClient;
using System.Data;

namespace TotalSport
{
    public partial class Login : System.Web.UI.Page
    {     string strCon = ConfigurationManager.ConnectionStrings["TotalSport"].ConnectionString;
        public SqlConnection conn;

        protected void Page_Load(object sender, EventArgs e)
        {
        
        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string Username = txtUserName.Text;
            string Password = txtPassword.Text;

            conn = new SqlConnection(strCon);

            SqlCommand cmd = new SqlCommand("TS_checkLogin", conn);
            cmd.CommandType = CommandType.StoredProcedure;

            SqlParameter[] arrParam = new SqlParameter[2];

            arrParam[0] = new SqlParameter("@Username", SqlDbType.VarChar);
            arrParam[0].Value = Username;
            arrParam[1] = new SqlParameter("@Password", SqlDbType.VarChar);
            arrParam[1].Value = Password;
            foreach (SqlParameter param in arrParam)
            {

                cmd.Parameters.Add(param);
            }



            conn.Open();
            int a=Convert.ToInt32( cmd.ExecuteScalar());

            if (a != -1)
            {
                Response.Redirect("JD.aspx");
                txtPassword.Text = "";
                txtUserName.Text = "";
            }
            else
            {
             SpnMsg.Style.Add ("display", "block");
                SpnMsg.InnerHtml = "Incorrect Login";
               
            }
        }
    }
}